$(function () {
    obj.init();
});
var obj = new function () {
    'use strict';
    return {
        boxFileErrorList: null,
        mac: null,
        url: null,
        page: 1,
        init: function () {
            this.mac = xhTool.getQuery('mac');
            this.boxFileErrorList = new xhDataGrid($('#boxFileErrorList'), 'box/getBoxFileErrorList',{'mac':this.mac});
            this.boxFileErrorList.parseToolbar().init();
            this.funObj().initSelectMac()
            this.listener();
        },
        listener: function () {
            var $this = this;

            //搜索
            $('#bt_search').click(function () {
                $this.mac = $('#macId').val();
                $this.url = $('#downUrl').val();
                $this.funObj().searchList();
            });
            //上一页
            $('#prePage').click(function () {
                $this.funObj().prevPage();
            });
            //下一页
            $('#nextPage').click(function () {
                $this.funObj().nextPage();
            });

        },
        funObj: function () {
            var $this = this;
            return {
                searchList: function () {
                    $this.boxFileErrorList.reload({mac: $this.mac, url: $this.url});
                },
                initSelectMac: function () {
                    $('#macId').combobox({
                        url:'getMacList',
                        valueField:'mac',
                        textField:'schoolName'
                    });
                    $('#macId').combobox('setValue', $this.mac);

                },
                prevPage: function () {
                    if ($this.page > 1) {
                        $this.page = $this.page-1;
                    }
                    $this.boxFileErrorList.reload({mac: $this.mac, url: $this.url, page: $this.page});
                },
                nextPage: function () {
                    $this.page = $this.page+1;
                    $this.boxFileErrorList.reload({mac: $this.mac, url: $this.url, page: $this.page});
                }

            }
        }
    }
}
